prediction-market-agent-tooling 0.62.0.dev493__tar.gz → 0.63.0.dev498__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.
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/agent.py +21 -5
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/betting_strategy.py +20 -5
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/agent_market.py +3 -1
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/blockchain_utils.py +6 -2
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/omen.py +1 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/seer/data_models.py +5 -63
- prediction_market_agent_tooling-0.63.0.dev498/prediction_market_agent_tooling/markets/seer/price_manager.py +119 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/seer/seer.py +101 -44
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +1 -1
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +47 -18
- prediction_market_agent_tooling-0.63.0.dev498/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +57 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/contract.py +11 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/cow/cow_order.py +47 -52
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +1 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/pyproject.toml +1 -1
- prediction_market_agent_tooling-0.62.0.dev493/prediction_market_agent_tooling/tools/cow/cow_manager.py +0 -112
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/README.md +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.62.0.dev493 → prediction_market_agent_tooling-0.63.0.dev498}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -65,7 +65,11 @@ from prediction_market_agent_tooling.tools.langfuse_ import langfuse_context, ob
|
|
65
65
|
from prediction_market_agent_tooling.tools.tokens.main_token import (
|
66
66
|
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES,
|
67
67
|
)
|
68
|
-
from prediction_market_agent_tooling.tools.utils import
|
68
|
+
from prediction_market_agent_tooling.tools.utils import (
|
69
|
+
DatetimeUTC,
|
70
|
+
check_not_none,
|
71
|
+
utcnow,
|
72
|
+
)
|
69
73
|
|
70
74
|
MAX_AVAILABLE_MARKETS = 1000
|
71
75
|
|
@@ -615,9 +619,9 @@ class DeployableTraderAgent(DeployablePredictionAgent):
|
|
615
619
|
return None
|
616
620
|
|
617
621
|
api_keys = APIKeys()
|
618
|
-
|
619
|
-
|
620
|
-
)
|
622
|
+
user_id = market.get_user_id(api_keys=api_keys)
|
623
|
+
|
624
|
+
existing_position = market.get_position(user_id=user_id)
|
621
625
|
trades = self.build_trades(
|
622
626
|
market=market,
|
623
627
|
answer=processed_market.answer,
|
@@ -643,8 +647,20 @@ class DeployableTraderAgent(DeployablePredictionAgent):
|
|
643
647
|
outcome=trade.outcome, amount=trade.amount
|
644
648
|
)
|
645
649
|
case TradeType.SELL:
|
650
|
+
# Get actual value of the position we are going to sell, and if it's less than we wanted to sell, simply sell all of it.
|
651
|
+
current_position_value = check_not_none(
|
652
|
+
market.get_position(user_id),
|
653
|
+
"Should exists if we are going to sell outcomes.",
|
654
|
+
).amounts_current[
|
655
|
+
market.get_outcome_str_from_bool(trade.outcome)
|
656
|
+
]
|
657
|
+
if current_position_value < trade.amount:
|
658
|
+
logger.warning(
|
659
|
+
f"Current value of position {trade.outcome=}, {current_position_value=} is less than the desired selling amount {trade.amount=}. Selling all."
|
660
|
+
)
|
646
661
|
id = market.sell_tokens(
|
647
|
-
outcome=trade.outcome,
|
662
|
+
outcome=trade.outcome,
|
663
|
+
amount=min(trade.amount, current_position_value),
|
648
664
|
)
|
649
665
|
case _:
|
650
666
|
raise ValueError(f"Unexpected trade type {trade.trade_type}.")
|
@@ -47,7 +47,8 @@ class BettingStrategy(ABC):
|
|
47
47
|
@staticmethod
|
48
48
|
def assert_buy_trade_wont_be_guaranteed_loss(
|
49
49
|
market: AgentMarket, trades: list[Trade]
|
50
|
-
) ->
|
50
|
+
) -> list[Trade]:
|
51
|
+
clean_trades = []
|
51
52
|
for trade in trades:
|
52
53
|
if trade.trade_type == TradeType.BUY:
|
53
54
|
outcome_tokens_to_get = market.get_buy_token_amount(
|
@@ -56,14 +57,28 @@ class BettingStrategy(ABC):
|
|
56
57
|
outcome_tokens_to_get_in_usd = market.get_token_in_usd(
|
57
58
|
outcome_tokens_to_get.as_token
|
58
59
|
)
|
60
|
+
|
61
|
+
if not outcome_tokens_to_get:
|
62
|
+
logger.info(
|
63
|
+
f"Could not determine buy_token_amount for trade {trade}. Skipping trade."
|
64
|
+
)
|
65
|
+
continue
|
66
|
+
|
59
67
|
if outcome_tokens_to_get_in_usd <= trade.amount:
|
60
68
|
raise GuaranteedLossError(
|
61
|
-
f"Trade {trade=} would result in guaranteed loss by getting only {outcome_tokens_to_get=}."
|
69
|
+
f"Trade {trade=} would result in guaranteed loss by getting only {outcome_tokens_to_get=}. Halting execution."
|
62
70
|
)
|
63
71
|
|
72
|
+
clean_trades.append(trade)
|
73
|
+
|
74
|
+
return clean_trades
|
75
|
+
|
64
76
|
@staticmethod
|
65
|
-
def
|
66
|
-
BettingStrategy.assert_buy_trade_wont_be_guaranteed_loss(
|
77
|
+
def filter_trades(market: AgentMarket, trades: list[Trade]) -> list[Trade]:
|
78
|
+
trades = BettingStrategy.assert_buy_trade_wont_be_guaranteed_loss(
|
79
|
+
market, trades
|
80
|
+
)
|
81
|
+
return trades
|
67
82
|
|
68
83
|
def _build_rebalance_trades_from_positions(
|
69
84
|
self,
|
@@ -109,7 +124,7 @@ class BettingStrategy(ABC):
|
|
109
124
|
trades.sort(key=lambda t: t.trade_type == TradeType.SELL)
|
110
125
|
|
111
126
|
# Run some sanity checks to not place unreasonable bets.
|
112
|
-
BettingStrategy.
|
127
|
+
trades = BettingStrategy.filter_trades(market, trades)
|
113
128
|
|
114
129
|
return trades
|
115
130
|
|
@@ -4,6 +4,7 @@ from enum import Enum
|
|
4
4
|
from eth_typing import ChecksumAddress
|
5
5
|
from pydantic import BaseModel, field_validator, model_validator
|
6
6
|
from pydantic_core.core_schema import FieldValidationInfo
|
7
|
+
from web3 import Web3
|
7
8
|
|
8
9
|
from prediction_market_agent_tooling.config import APIKeys
|
9
10
|
from prediction_market_agent_tooling.gtypes import (
|
@@ -235,7 +236,7 @@ class AgentMarket(BaseModel):
|
|
235
236
|
|
236
237
|
def get_buy_token_amount(
|
237
238
|
self, bet_amount: USD | CollateralToken, direction: bool
|
238
|
-
) -> OutcomeToken:
|
239
|
+
) -> OutcomeToken | None:
|
239
240
|
raise NotImplementedError("Subclasses must implement this method")
|
240
241
|
|
241
242
|
def sell_tokens(self, outcome: bool, amount: USD | OutcomeToken) -> str:
|
@@ -293,6 +294,7 @@ class AgentMarket(BaseModel):
|
|
293
294
|
traded_market: ProcessedTradedMarket | None,
|
294
295
|
keys: APIKeys,
|
295
296
|
agent_name: str,
|
297
|
+
web3: Web3 | None = None,
|
296
298
|
) -> None:
|
297
299
|
"""
|
298
300
|
If market allows to upload trades somewhere, implement it in this method.
|
@@ -22,10 +22,11 @@ def store_trades(
|
|
22
22
|
traded_market: ProcessedTradedMarket | None,
|
23
23
|
keys: APIKeys,
|
24
24
|
agent_name: str,
|
25
|
+
web3: Web3 | None = None,
|
25
26
|
) -> None:
|
26
27
|
if traded_market is None:
|
27
28
|
logger.warning(f"No prediction for market {market_id}, not storing anything.")
|
28
|
-
return
|
29
|
+
return None
|
29
30
|
|
30
31
|
reasoning = traded_market.answer.reasoning if traded_market.answer.reasoning else ""
|
31
32
|
|
@@ -37,8 +38,10 @@ def store_trades(
|
|
37
38
|
)
|
38
39
|
ipfs_hash_decoded = ipfscidv0_to_byte32(ipfs_hash)
|
39
40
|
|
41
|
+
# tx_hashes must be list of bytes32 (see Solidity contract).
|
42
|
+
# For regular tx hashes that's fine, but for other types of IDs we take the first 32 bytes (orderDigest).
|
40
43
|
tx_hashes = [
|
41
|
-
HexBytes(HexStr(i.id)) for i in traded_market.trades if i.id is not None
|
44
|
+
HexBytes(HexStr(i.id[:32])) for i in traded_market.trades if i.id is not None
|
42
45
|
]
|
43
46
|
prediction = ContractPrediction(
|
44
47
|
publisher=keys.bet_from_address,
|
@@ -50,6 +53,7 @@ def store_trades(
|
|
50
53
|
api_keys=keys,
|
51
54
|
market_address=Web3.to_checksum_address(market_id),
|
52
55
|
prediction=prediction,
|
56
|
+
web3=web3,
|
53
57
|
)
|
54
58
|
logger.info(
|
55
59
|
f"Added prediction to market {market_id}. - receipt {tx_receipt['transactionHash'].hex()}."
|
@@ -5,9 +5,9 @@ from urllib.parse import urljoin
|
|
5
5
|
|
6
6
|
from pydantic import BaseModel, ConfigDict, Field
|
7
7
|
from web3 import Web3
|
8
|
-
from web3.constants import ADDRESS_ZERO
|
9
8
|
|
10
9
|
from prediction_market_agent_tooling.config import RPCConfig
|
10
|
+
from prediction_market_agent_tooling.gtypes import ChecksumAddress, HexAddress, HexBytes
|
11
11
|
from prediction_market_agent_tooling.gtypes import (
|
12
12
|
ChecksumAddress,
|
13
13
|
CollateralToken,
|
@@ -19,7 +19,9 @@ from prediction_market_agent_tooling.gtypes import (
|
|
19
19
|
)
|
20
20
|
from prediction_market_agent_tooling.loggers import logger
|
21
21
|
from prediction_market_agent_tooling.markets.data_models import Resolution
|
22
|
-
from prediction_market_agent_tooling.
|
22
|
+
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
|
23
|
+
SeerParentMarket,
|
24
|
+
)
|
23
25
|
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
24
26
|
|
25
27
|
|
@@ -84,10 +86,6 @@ class SeerOutcomeEnum(str, Enum):
|
|
84
86
|
raise ValueError(f"Unknown outcome: {self}")
|
85
87
|
|
86
88
|
|
87
|
-
class SeerParentMarket(BaseModel):
|
88
|
-
id: HexBytes
|
89
|
-
|
90
|
-
|
91
89
|
SEER_BASE_URL = "https://app.seer.pm"
|
92
90
|
|
93
91
|
|
@@ -110,6 +108,7 @@ class SeerMarket(BaseModel):
|
|
110
108
|
has_answers: bool | None = Field(alias="hasAnswers")
|
111
109
|
payout_reported: bool = Field(alias="payoutReported")
|
112
110
|
payout_numerators: list[int] = Field(alias="payoutNumerators")
|
111
|
+
outcomes_supply: int = Field(alias="outcomesSupply")
|
113
112
|
|
114
113
|
@property
|
115
114
|
def has_valid_answer(self) -> bool:
|
@@ -186,64 +185,7 @@ class SeerMarket(BaseModel):
|
|
186
185
|
def created_time(self) -> DatetimeUTC:
|
187
186
|
return DatetimeUTC.to_datetime_utc(self.block_timestamp)
|
188
187
|
|
189
|
-
@property
|
190
|
-
def current_p_yes(self) -> Probability:
|
191
|
-
price_data = {}
|
192
|
-
for idx in range(len(self.outcomes)):
|
193
|
-
wrapped_token = self.wrapped_tokens[idx]
|
194
|
-
price = self._get_price_for_token(
|
195
|
-
token=Web3.to_checksum_address(wrapped_token)
|
196
|
-
)
|
197
|
-
price_data[idx] = price
|
198
|
-
|
199
|
-
if sum(price_data.values()) == 0:
|
200
|
-
logger.warning(
|
201
|
-
f"Could not get p_yes for market {self.id.hex()}, all price quotes are 0."
|
202
|
-
)
|
203
|
-
return Probability(0)
|
204
|
-
|
205
|
-
yes_idx = self.outcome_as_enums[SeerOutcomeEnum.YES]
|
206
|
-
price_yes = price_data[yes_idx] / sum(price_data.values())
|
207
|
-
return Probability(price_yes)
|
208
|
-
|
209
|
-
def _get_price_for_token(self, token: ChecksumAddress) -> float:
|
210
|
-
collateral_exchange_amount = CollateralToken(1).as_wei
|
211
|
-
try:
|
212
|
-
quote = CowManager().get_quote(
|
213
|
-
collateral_token=self.collateral_token_contract_address_checksummed,
|
214
|
-
buy_token=token,
|
215
|
-
sell_amount=collateral_exchange_amount,
|
216
|
-
)
|
217
|
-
except Exception as e:
|
218
|
-
logger.warning(f"Could not get quote for {token=}, returning price 0. {e=}")
|
219
|
-
return 0
|
220
|
-
|
221
|
-
return collateral_exchange_amount.value / float(quote.quote.buyAmount.root)
|
222
|
-
|
223
188
|
@property
|
224
189
|
def url(self) -> str:
|
225
190
|
chain_id = RPCConfig().chain_id
|
226
191
|
return urljoin(SEER_BASE_URL, f"markets/{chain_id}/{self.id.hex()}")
|
227
|
-
|
228
|
-
|
229
|
-
class SeerToken(BaseModel):
|
230
|
-
id: HexBytes
|
231
|
-
name: str
|
232
|
-
symbol: str
|
233
|
-
|
234
|
-
|
235
|
-
class SeerPool(BaseModel):
|
236
|
-
model_config = ConfigDict(populate_by_name=True)
|
237
|
-
id: HexBytes
|
238
|
-
liquidity: int
|
239
|
-
token0: SeerToken
|
240
|
-
token1: SeerToken
|
241
|
-
|
242
|
-
|
243
|
-
class NewMarketEvent(BaseModel):
|
244
|
-
market: HexAddress
|
245
|
-
marketName: str
|
246
|
-
parentMarket: HexAddress
|
247
|
-
conditionId: HexBytes
|
248
|
-
questionId: HexBytes
|
249
|
-
questionsIds: list[HexBytes]
|
@@ -0,0 +1,119 @@
|
|
1
|
+
from functools import lru_cache
|
2
|
+
|
3
|
+
from web3 import Web3
|
4
|
+
|
5
|
+
from prediction_market_agent_tooling.gtypes import (
|
6
|
+
ChecksumAddress,
|
7
|
+
Probability,
|
8
|
+
xdai_type,
|
9
|
+
Wei,
|
10
|
+
)
|
11
|
+
from prediction_market_agent_tooling.loggers import logger
|
12
|
+
from prediction_market_agent_tooling.markets.seer.data_models import (
|
13
|
+
SeerMarket,
|
14
|
+
SeerOutcomeEnum,
|
15
|
+
)
|
16
|
+
from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
|
17
|
+
SeerSubgraphHandler,
|
18
|
+
)
|
19
|
+
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import SeerPool
|
20
|
+
from prediction_market_agent_tooling.tools.cow.cow_order import get_quote
|
21
|
+
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
|
22
|
+
from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
|
23
|
+
|
24
|
+
|
25
|
+
class PriceManager:
|
26
|
+
def __init__(self, seer_market: SeerMarket, seer_subgraph: SeerSubgraphHandler):
|
27
|
+
self.seer_market = seer_market
|
28
|
+
self.seer_subgraph = seer_subgraph
|
29
|
+
|
30
|
+
@staticmethod
|
31
|
+
def build(market_id: HexBytes) -> "PriceManager":
|
32
|
+
s = SeerSubgraphHandler()
|
33
|
+
market = s.get_market_by_id(market_id=market_id)
|
34
|
+
return PriceManager(seer_market=market, seer_subgraph=s)
|
35
|
+
|
36
|
+
def _log_track_price_normalization_diff(
|
37
|
+
self, old_price: float, normalized_price: float, max_price_diff: float = 0.05
|
38
|
+
) -> None:
|
39
|
+
price_diff_pct = abs(old_price - normalized_price) / old_price
|
40
|
+
if price_diff_pct > max_price_diff:
|
41
|
+
logger.info(
|
42
|
+
f"{price_diff_pct=} larger than {max_price_diff=} for seer market {self.seer_market.id.hex()} "
|
43
|
+
)
|
44
|
+
|
45
|
+
def current_p_yes(self) -> Probability | None:
|
46
|
+
# Inspired by https://github.com/seer-pm/demo/blob/ca682153a6b4d4dd3dcc4ad8bdcbe32202fc8fe7/web/src/hooks/useMarketOdds.ts#L15
|
47
|
+
price_data = {}
|
48
|
+
for idx, wrapped_token in enumerate(self.seer_market.wrapped_tokens):
|
49
|
+
price = self.get_price_for_token(
|
50
|
+
token=Web3.to_checksum_address(wrapped_token),
|
51
|
+
)
|
52
|
+
|
53
|
+
price_data[idx] = price
|
54
|
+
|
55
|
+
price_yes = price_data[self.seer_market.outcome_as_enums[SeerOutcomeEnum.YES]]
|
56
|
+
price_no = price_data[self.seer_market.outcome_as_enums[SeerOutcomeEnum.NO]]
|
57
|
+
|
58
|
+
# We only return a probability if we have both price_yes and price_no, since we could place bets
|
59
|
+
# in both sides hence we need current probabilities for both outcomes.
|
60
|
+
if price_yes and price_no:
|
61
|
+
# If other outcome`s price is None, we set it to 0.
|
62
|
+
total_price = sum(
|
63
|
+
price if price is not None else 0.0 for price in price_data.values()
|
64
|
+
)
|
65
|
+
normalized_price_yes = price_yes / total_price
|
66
|
+
self._log_track_price_normalization_diff(
|
67
|
+
old_price=price_yes, normalized_price=normalized_price_yes
|
68
|
+
)
|
69
|
+
return Probability(normalized_price_yes)
|
70
|
+
else:
|
71
|
+
return None
|
72
|
+
|
73
|
+
@lru_cache(typed=True)
|
74
|
+
def get_price_for_token(
|
75
|
+
self,
|
76
|
+
token: ChecksumAddress,
|
77
|
+
collateral_exchange_amount: Wei = xdai_to_wei(xdai_type(1)),
|
78
|
+
) -> float | None:
|
79
|
+
try:
|
80
|
+
quote = get_quote(
|
81
|
+
amount_wei=collateral_exchange_amount,
|
82
|
+
sell_token=self.seer_market.collateral_token_contract_address_checksummed,
|
83
|
+
buy_token=token,
|
84
|
+
)
|
85
|
+
|
86
|
+
except Exception as e:
|
87
|
+
logger.warning(
|
88
|
+
f"Could not get quote for {token=} from Cow, exception {e=}. Falling back to pools. "
|
89
|
+
)
|
90
|
+
return self.get_token_price_from_pools(token=token)
|
91
|
+
|
92
|
+
return collateral_exchange_amount / float(quote.quote.buyAmount.root)
|
93
|
+
|
94
|
+
@staticmethod
|
95
|
+
def _pool_token0_matches_token(token: ChecksumAddress, pool: SeerPool) -> bool:
|
96
|
+
return pool.token0.id.hex().lower() == token.lower()
|
97
|
+
|
98
|
+
def get_token_price_from_pools(
|
99
|
+
self,
|
100
|
+
token: ChecksumAddress,
|
101
|
+
) -> float | None:
|
102
|
+
pool = SeerSubgraphHandler().get_pool_by_token(
|
103
|
+
token_address=token,
|
104
|
+
collateral_address=self.seer_market.collateral_token_contract_address_checksummed,
|
105
|
+
)
|
106
|
+
|
107
|
+
if not pool:
|
108
|
+
logger.warning(f"Could not find a pool for {token=}")
|
109
|
+
return None
|
110
|
+
|
111
|
+
# The mapping below is odd but surprisingly the Algebra subgraph delivers the token1Price
|
112
|
+
# for the token0 and the token0Price for the token1 pool.
|
113
|
+
# For example, in a outcomeYES (token0)/sDAI pool (token1), token1Price is the price of outcomeYES in units of sDAI.
|
114
|
+
price_in_collateral_units = (
|
115
|
+
pool.token1Price
|
116
|
+
if self._pool_token0_matches_token(token=token, pool=pool)
|
117
|
+
else pool.token0Price
|
118
|
+
)
|
119
|
+
return price_in_collateral_units
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import typing as t
|
2
2
|
|
3
|
+
import tenacity
|
4
|
+
from eth_pydantic_types import HexStr
|
3
5
|
from eth_typing import ChecksumAddress
|
4
6
|
from web3 import Web3
|
5
7
|
from web3.types import TxReceipt
|
@@ -11,6 +13,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
11
13
|
HexAddress,
|
12
14
|
HexBytes,
|
13
15
|
OutcomeStr,
|
16
|
+
Wei,
|
14
17
|
OutcomeToken,
|
15
18
|
OutcomeWei,
|
16
19
|
xDai,
|
@@ -20,33 +23,33 @@ from prediction_market_agent_tooling.markets.agent_market import (
|
|
20
23
|
AgentMarket,
|
21
24
|
FilterBy,
|
22
25
|
ProcessedMarket,
|
23
|
-
ProcessedTradedMarket,
|
24
26
|
SortBy,
|
27
|
+
ProcessedTradedMarket,
|
25
28
|
)
|
26
|
-
from prediction_market_agent_tooling.markets.blockchain_utils import store_trades
|
27
29
|
from prediction_market_agent_tooling.markets.data_models import ExistingPosition
|
28
30
|
from prediction_market_agent_tooling.markets.market_fees import MarketFees
|
29
31
|
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
|
30
32
|
from prediction_market_agent_tooling.markets.seer.data_models import (
|
31
|
-
NewMarketEvent,
|
32
33
|
SeerMarket,
|
33
34
|
SeerOutcomeEnum,
|
34
35
|
)
|
36
|
+
from prediction_market_agent_tooling.markets.seer.price_manager import PriceManager
|
35
37
|
from prediction_market_agent_tooling.markets.seer.seer_contracts import (
|
36
38
|
SeerMarketFactory,
|
37
39
|
)
|
38
40
|
from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
|
39
41
|
SeerSubgraphHandler,
|
40
42
|
)
|
43
|
+
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
|
44
|
+
NewMarketEvent,
|
45
|
+
)
|
46
|
+
from prediction_market_agent_tooling.tools.balances import get_balances
|
41
47
|
from prediction_market_agent_tooling.tools.contract import (
|
42
48
|
ContractERC20OnGnosisChain,
|
43
49
|
init_collateral_token_contract,
|
44
50
|
to_gnosis_chain_contract,
|
45
51
|
)
|
46
|
-
from prediction_market_agent_tooling.tools.cow.
|
47
|
-
CowManager,
|
48
|
-
NoLiquidityAvailableOnCowException,
|
49
|
-
)
|
52
|
+
from prediction_market_agent_tooling.tools.cow.cow_order import swap_tokens_waiting
|
50
53
|
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
51
54
|
from prediction_market_agent_tooling.tools.tokens.auto_deposit import (
|
52
55
|
auto_deposit_collateral_token,
|
@@ -87,19 +90,16 @@ class SeerAgentMarket(AgentMarket):
|
|
87
90
|
agent_name: str,
|
88
91
|
) -> None:
|
89
92
|
"""On Seer, we have to store predictions along with trades, see `store_trades`."""
|
93
|
+
pass
|
90
94
|
|
91
95
|
def store_trades(
|
92
96
|
self,
|
93
97
|
traded_market: ProcessedTradedMarket | None,
|
94
98
|
keys: APIKeys,
|
95
99
|
agent_name: str,
|
100
|
+
web3: Web3 | None = None,
|
96
101
|
) -> None:
|
97
|
-
|
98
|
-
market_id=self.id,
|
99
|
-
traded_market=traded_market,
|
100
|
-
keys=keys,
|
101
|
-
agent_name=agent_name,
|
102
|
-
)
|
102
|
+
pass
|
103
103
|
|
104
104
|
def get_token_in_usd(self, x: CollateralToken) -> USD:
|
105
105
|
return get_token_in_usd(x, self.collateral_token_contract_address_checksummed)
|
@@ -108,20 +108,24 @@ class SeerAgentMarket(AgentMarket):
|
|
108
108
|
return get_usd_in_token(x, self.collateral_token_contract_address_checksummed)
|
109
109
|
|
110
110
|
def get_buy_token_amount(
|
111
|
-
self, bet_amount:
|
112
|
-
) -> OutcomeToken:
|
111
|
+
self, bet_amount: BetAmount, direction: bool
|
112
|
+
) -> OutcomeToken | None:
|
113
113
|
"""Returns number of outcome tokens returned for a given bet expressed in collateral units."""
|
114
114
|
|
115
115
|
outcome_token = self.get_wrapped_token_for_outcome(direction)
|
116
116
|
bet_amount_in_tokens = self.get_in_token(bet_amount)
|
117
117
|
bet_amount_in_wei = bet_amount_in_tokens.as_wei
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
collateral_token=self.collateral_token_contract_address_checksummed,
|
119
|
+
p = PriceManager.build(market_id=HexBytes(HexStr(self.id)))
|
120
|
+
price_in_collateral_units = p.get_price_for_token(
|
121
|
+
token=outcome_token, collateral_exchange_amount=bet_amount_in_wei
|
123
122
|
)
|
124
|
-
|
123
|
+
if not price_in_collateral_units:
|
124
|
+
logger.info(f"Could not get price for token {outcome_token}")
|
125
|
+
return None
|
126
|
+
|
127
|
+
buy_amount = bet_amount_in_wei / price_in_collateral_units
|
128
|
+
sell_amount = OutcomeWei(buy_amount).as_outcome_token
|
125
129
|
return sell_amount
|
126
130
|
|
127
131
|
def get_outcome_str_from_bool(self, outcome: bool) -> OutcomeStr:
|
@@ -185,7 +189,17 @@ class SeerAgentMarket(AgentMarket):
|
|
185
189
|
return OmenAgentMarket.verify_operational_balance(api_keys=api_keys)
|
186
190
|
|
187
191
|
@staticmethod
|
188
|
-
def
|
192
|
+
def from_data_model_with_subgraph(
|
193
|
+
model: SeerMarket, seer_subgraph: SeerSubgraphHandler
|
194
|
+
) -> "SeerAgentMarket" | None:
|
195
|
+
p = PriceManager(seer_market=model, seer_subgraph=seer_subgraph)
|
196
|
+
current_p_yes = p.current_p_yes()
|
197
|
+
if not current_p_yes:
|
198
|
+
logger.info(
|
199
|
+
f"p_yes for market {model.id.hex()} could not be calculated. Skipping."
|
200
|
+
)
|
201
|
+
return None
|
202
|
+
|
189
203
|
return SeerAgentMarket(
|
190
204
|
id=model.id.hex(),
|
191
205
|
question=model.title,
|
@@ -201,7 +215,7 @@ class SeerAgentMarket(AgentMarket):
|
|
201
215
|
outcome_token_pool=None,
|
202
216
|
resolution=model.get_resolution_enum(),
|
203
217
|
volume=None,
|
204
|
-
current_p_yes=
|
218
|
+
current_p_yes=current_p_yes,
|
205
219
|
seer_outcomes=model.outcome_as_enums,
|
206
220
|
)
|
207
221
|
|
@@ -213,31 +227,31 @@ class SeerAgentMarket(AgentMarket):
|
|
213
227
|
created_after: t.Optional[DatetimeUTC] = None,
|
214
228
|
excluded_questions: set[str] | None = None,
|
215
229
|
) -> t.Sequence["SeerAgentMarket"]:
|
230
|
+
seer_subgraph = SeerSubgraphHandler()
|
231
|
+
markets = seer_subgraph.get_binary_markets(
|
232
|
+
limit=limit, sort_by=sort_by, filter_by=filter_by
|
233
|
+
)
|
234
|
+
|
235
|
+
# We exclude the None values below because `from_data_model_with_subgraph` can return None, which
|
236
|
+
# represents an invalid market.
|
216
237
|
return [
|
217
|
-
|
218
|
-
for m in
|
219
|
-
|
220
|
-
|
221
|
-
|
238
|
+
market
|
239
|
+
for m in markets
|
240
|
+
if (
|
241
|
+
market := SeerAgentMarket.from_data_model_with_subgraph(
|
242
|
+
model=m, seer_subgraph=seer_subgraph
|
243
|
+
)
|
222
244
|
)
|
245
|
+
is not None
|
223
246
|
]
|
224
247
|
|
225
248
|
def has_liquidity_for_outcome(self, outcome: bool) -> bool:
|
226
249
|
outcome_token = self.get_wrapped_token_for_outcome(outcome)
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
1
|
233
|
-
).as_wei, # we take 1 as a baseline value for common trades the agents take.
|
234
|
-
)
|
235
|
-
return True
|
236
|
-
except NoLiquidityAvailableOnCowException:
|
237
|
-
logger.info(
|
238
|
-
f"Could not get a quote for {outcome_token=} {outcome=}, returning no liquidity"
|
239
|
-
)
|
240
|
-
return False
|
250
|
+
pool = SeerSubgraphHandler().get_pool_by_token(
|
251
|
+
token_address=outcome_token,
|
252
|
+
collateral_address=self.collateral_token_contract_address_checksummed,
|
253
|
+
)
|
254
|
+
return pool is not None and pool.liquidity > 0
|
241
255
|
|
242
256
|
def has_liquidity(self) -> bool:
|
243
257
|
# We conservatively define a market as having liquidity if it has liquidity for the `True` outcome token AND the `False` outcome token.
|
@@ -281,14 +295,57 @@ class SeerAgentMarket(AgentMarket):
|
|
281
295
|
)
|
282
296
|
|
283
297
|
outcome_token = self.get_wrapped_token_for_outcome(outcome)
|
284
|
-
|
285
|
-
|
286
|
-
|
298
|
+
amount_to_trade = xdai_type(amount.amount)
|
299
|
+
|
300
|
+
# Sell sDAI using token address
|
301
|
+
order_metadata = swap_tokens_waiting(
|
302
|
+
amount_wei=xdai_to_wei(amount_to_trade),
|
287
303
|
sell_token=collateral_contract.address,
|
288
304
|
buy_token=outcome_token,
|
289
305
|
api_keys=api_keys,
|
290
306
|
web3=web3,
|
291
307
|
)
|
308
|
+
logger.debug(
|
309
|
+
f"Purchased {outcome_token} in exchange for {collateral_contract.address}. Order details {order_metadata}"
|
310
|
+
)
|
311
|
+
|
312
|
+
return order_metadata.uid.root
|
313
|
+
|
314
|
+
@tenacity.retry(
|
315
|
+
stop=tenacity.stop_after_attempt(3),
|
316
|
+
wait=tenacity.wait_fixed(1),
|
317
|
+
after=lambda x: logger.debug(
|
318
|
+
f"seer_sell_outcome_tx failed, {x.attempt_number=}."
|
319
|
+
),
|
320
|
+
)
|
321
|
+
def sell_tokens(
|
322
|
+
self,
|
323
|
+
outcome: bool,
|
324
|
+
amount: TokenAmount,
|
325
|
+
auto_withdraw: bool = True,
|
326
|
+
api_keys: APIKeys | None = None,
|
327
|
+
web3: Web3 | None = None,
|
328
|
+
) -> str:
|
329
|
+
"""
|
330
|
+
Sells the given number of shares for the given outcome in the given market.
|
331
|
+
"""
|
332
|
+
outcome_token = self.get_wrapped_token_for_outcome(outcome)
|
333
|
+
api_keys = api_keys if api_keys is not None else APIKeys()
|
334
|
+
amount_to_trade = xdai_type(amount.amount)
|
335
|
+
|
336
|
+
order_metadata = swap_tokens_waiting(
|
337
|
+
amount_wei=xdai_to_wei(amount_to_trade),
|
338
|
+
sell_token=outcome_token,
|
339
|
+
buy_token=Web3.to_checksum_address(
|
340
|
+
self.collateral_token_contract_address_checksummed
|
341
|
+
),
|
342
|
+
api_keys=api_keys,
|
343
|
+
web3=web3,
|
344
|
+
)
|
345
|
+
|
346
|
+
logger.debug(
|
347
|
+
f"Sold {outcome_token} in exchange for {self.collateral_token_contract_address_checksummed}. Order details {order_metadata}"
|
348
|
+
)
|
292
349
|
|
293
350
|
return order_metadata.uid.root
|
294
351
|
|
@@ -11,7 +11,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
11
11
|
OutcomeStr,
|
12
12
|
xDai,
|
13
13
|
)
|
14
|
-
from prediction_market_agent_tooling.markets.seer.
|
14
|
+
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
|
15
15
|
CreateCategoricalMarketsParams,
|
16
16
|
)
|
17
17
|
from prediction_market_agent_tooling.tools.contract import (
|