prediction-market-agent-tooling 0.58.3__tar.gz → 0.58.4__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.58.3 → prediction_market_agent_tooling-0.58.4}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/agent.py +3 -1
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/betting_strategy.py +2 -6
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/agent_market.py +1 -2
- prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/markets/blockchain_utils.py +82 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/data_models.py +1 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/markets.py +4 -1
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/omen.py +12 -62
- prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/markets/seer/data_models.py +249 -0
- prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/markets/seer/seer.py +362 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +103 -21
- prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/tools/cow/cow_manager.py +113 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/pyproject.toml +1 -1
- prediction_market_agent_tooling-0.58.3/prediction_market_agent_tooling/markets/seer/data_models.py +0 -70
- prediction_market_agent_tooling-0.58.3/prediction_market_agent_tooling/markets/seer/seer.py +0 -94
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/README.md +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/agentcommunication.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/abis/simpletreasury.abi.json +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.58.3 → prediction_market_agent_tooling-0.58.4}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -64,7 +64,7 @@ from prediction_market_agent_tooling.tools.is_predictable import is_predictable_
|
|
64
64
|
from prediction_market_agent_tooling.tools.langfuse_ import langfuse_context, observe
|
65
65
|
from prediction_market_agent_tooling.tools.utils import DatetimeUTC, utcnow
|
66
66
|
|
67
|
-
MAX_AVAILABLE_MARKETS =
|
67
|
+
MAX_AVAILABLE_MARKETS = 1000
|
68
68
|
|
69
69
|
|
70
70
|
def initialize_langfuse(enable_langfuse: bool) -> None:
|
@@ -430,6 +430,7 @@ class DeployablePredictionAgent(DeployableAgent):
|
|
430
430
|
logger.info(f"Market '{market.question}' doesn't meet the criteria.")
|
431
431
|
answer = None
|
432
432
|
else:
|
433
|
+
logger.info(f"Answering market '{market.question}'.")
|
433
434
|
answer = self.answer_binary_market(market)
|
434
435
|
|
435
436
|
processed_market = (
|
@@ -522,6 +523,7 @@ class DeployableTraderAgent(DeployablePredictionAgent):
|
|
522
523
|
MarketType.OMEN,
|
523
524
|
MarketType.MANIFOLD,
|
524
525
|
MarketType.POLYMARKET,
|
526
|
+
MarketType.SEER,
|
525
527
|
]
|
526
528
|
|
527
529
|
def __init__(
|
@@ -13,7 +13,6 @@ from prediction_market_agent_tooling.markets.data_models import (
|
|
13
13
|
Trade,
|
14
14
|
TradeType,
|
15
15
|
)
|
16
|
-
from prediction_market_agent_tooling.markets.omen.data_models import get_boolean_outcome
|
17
16
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
18
17
|
get_buy_outcome_token_amount,
|
19
18
|
)
|
@@ -94,11 +93,8 @@ class BettingStrategy(ABC):
|
|
94
93
|
sell price is higher.
|
95
94
|
"""
|
96
95
|
trades = []
|
97
|
-
for
|
98
|
-
market.get_outcome_str_from_bool(
|
99
|
-
market.get_outcome_str_from_bool(False),
|
100
|
-
]:
|
101
|
-
outcome_bool = get_boolean_outcome(outcome)
|
96
|
+
for outcome_bool in [True, False]:
|
97
|
+
outcome = market.get_outcome_str_from_bool(outcome_bool)
|
102
98
|
prev_amount: TokenAmount = (
|
103
99
|
existing_position.amounts[outcome]
|
104
100
|
if existing_position and outcome in existing_position.amounts
|
@@ -284,8 +284,7 @@ class AgentMarket(BaseModel):
|
|
284
284
|
def has_unsuccessful_resolution(self) -> bool:
|
285
285
|
return self.resolution in [Resolution.CANCEL, Resolution.MKT]
|
286
286
|
|
287
|
-
|
288
|
-
def get_outcome_str_from_bool(outcome: bool) -> OutcomeStr:
|
287
|
+
def get_outcome_str_from_bool(self, outcome: bool) -> OutcomeStr:
|
289
288
|
raise NotImplementedError("Subclasses must implement this method")
|
290
289
|
|
291
290
|
def get_outcome_str(self, outcome_index: int) -> str:
|
prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/markets/blockchain_utils.py
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
from web3 import Web3
|
2
|
+
from web3.constants import HASH_ZERO
|
3
|
+
|
4
|
+
from prediction_market_agent_tooling.config import APIKeys
|
5
|
+
from prediction_market_agent_tooling.gtypes import (
|
6
|
+
ChecksumAddress,
|
7
|
+
HexBytes,
|
8
|
+
HexStr,
|
9
|
+
xDai,
|
10
|
+
xdai_type,
|
11
|
+
)
|
12
|
+
from prediction_market_agent_tooling.loggers import logger
|
13
|
+
from prediction_market_agent_tooling.markets.agent_market import ProcessedTradedMarket
|
14
|
+
from prediction_market_agent_tooling.markets.omen.data_models import (
|
15
|
+
ContractPrediction,
|
16
|
+
IPFSAgentResult,
|
17
|
+
)
|
18
|
+
from prediction_market_agent_tooling.markets.omen.omen_contracts import (
|
19
|
+
OmenAgentResultMappingContract,
|
20
|
+
)
|
21
|
+
from prediction_market_agent_tooling.tools.balances import get_balances
|
22
|
+
from prediction_market_agent_tooling.tools.ipfs.ipfs_handler import IPFSHandler
|
23
|
+
from prediction_market_agent_tooling.tools.utils import BPS_CONSTANT
|
24
|
+
from prediction_market_agent_tooling.tools.web3_utils import ipfscidv0_to_byte32
|
25
|
+
|
26
|
+
|
27
|
+
def get_total_balance(
|
28
|
+
address: ChecksumAddress,
|
29
|
+
web3: Web3 | None = None,
|
30
|
+
sum_xdai: bool = True,
|
31
|
+
sum_wxdai: bool = True,
|
32
|
+
) -> xDai:
|
33
|
+
"""
|
34
|
+
Checks if the total balance of xDai and wxDai in the wallet is above the minimum required balance.
|
35
|
+
"""
|
36
|
+
current_balances = get_balances(address, web3)
|
37
|
+
# xDai and wxDai have equal value and can be exchanged for almost no cost, so we can sum them up.
|
38
|
+
total_balance = 0.0
|
39
|
+
if sum_xdai:
|
40
|
+
total_balance += current_balances.xdai
|
41
|
+
if sum_wxdai:
|
42
|
+
total_balance += current_balances.wxdai
|
43
|
+
return xdai_type(total_balance)
|
44
|
+
|
45
|
+
|
46
|
+
def store_trades(
|
47
|
+
market_id: str,
|
48
|
+
traded_market: ProcessedTradedMarket | None,
|
49
|
+
keys: APIKeys,
|
50
|
+
agent_name: str,
|
51
|
+
) -> None:
|
52
|
+
if traded_market is None:
|
53
|
+
logger.warning(f"No prediction for market {market_id}, not storing anything.")
|
54
|
+
return
|
55
|
+
|
56
|
+
reasoning = traded_market.answer.reasoning if traded_market.answer.reasoning else ""
|
57
|
+
|
58
|
+
ipfs_hash_decoded = HexBytes(HASH_ZERO)
|
59
|
+
if keys.enable_ipfs_upload:
|
60
|
+
logger.info("Storing prediction on IPFS.")
|
61
|
+
ipfs_hash = IPFSHandler(keys).store_agent_result(
|
62
|
+
IPFSAgentResult(reasoning=reasoning, agent_name=agent_name)
|
63
|
+
)
|
64
|
+
ipfs_hash_decoded = ipfscidv0_to_byte32(ipfs_hash)
|
65
|
+
|
66
|
+
tx_hashes = [
|
67
|
+
HexBytes(HexStr(i.id)) for i in traded_market.trades if i.id is not None
|
68
|
+
]
|
69
|
+
prediction = ContractPrediction(
|
70
|
+
publisher=keys.bet_from_address,
|
71
|
+
ipfs_hash=ipfs_hash_decoded,
|
72
|
+
tx_hashes=tx_hashes,
|
73
|
+
estimated_probability_bps=int(traded_market.answer.p_yes * BPS_CONSTANT),
|
74
|
+
)
|
75
|
+
tx_receipt = OmenAgentResultMappingContract().add_prediction(
|
76
|
+
api_keys=keys,
|
77
|
+
market_address=Web3.to_checksum_address(market_id),
|
78
|
+
prediction=prediction,
|
79
|
+
)
|
80
|
+
logger.info(
|
81
|
+
f"Added prediction to market {market_id}. - receipt {tx_receipt['transactionHash'].hex()}."
|
82
|
+
)
|
@@ -28,6 +28,7 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
|
28
28
|
from prediction_market_agent_tooling.markets.polymarket.polymarket import (
|
29
29
|
PolymarketAgentMarket,
|
30
30
|
)
|
31
|
+
from prediction_market_agent_tooling.markets.seer.seer import SeerAgentMarket
|
31
32
|
from prediction_market_agent_tooling.tools.utils import (
|
32
33
|
DatetimeUTC,
|
33
34
|
should_not_happen,
|
@@ -41,6 +42,7 @@ class MarketType(str, Enum):
|
|
41
42
|
MANIFOLD = "manifold"
|
42
43
|
POLYMARKET = "polymarket"
|
43
44
|
METACULUS = "metaculus"
|
45
|
+
SEER = "seer"
|
44
46
|
|
45
47
|
@property
|
46
48
|
def market_class(self) -> type[AgentMarket]:
|
@@ -56,7 +58,7 @@ class MarketType(str, Enum):
|
|
56
58
|
|
57
59
|
@property
|
58
60
|
def is_blockchain_market(self) -> bool:
|
59
|
-
return self in [MarketType.OMEN, MarketType.POLYMARKET]
|
61
|
+
return self in [MarketType.OMEN, MarketType.POLYMARKET, MarketType.SEER]
|
60
62
|
|
61
63
|
|
62
64
|
MARKET_TYPE_TO_AGENT_MARKET: dict[MarketType, type[AgentMarket]] = {
|
@@ -64,6 +66,7 @@ MARKET_TYPE_TO_AGENT_MARKET: dict[MarketType, type[AgentMarket]] = {
|
|
64
66
|
MarketType.OMEN: OmenAgentMarket,
|
65
67
|
MarketType.POLYMARKET: PolymarketAgentMarket,
|
66
68
|
MarketType.METACULUS: MetaculusAgentMarket,
|
69
|
+
MarketType.SEER: SeerAgentMarket,
|
67
70
|
}
|
68
71
|
|
69
72
|
JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET: dict[MarketType, type[JobAgentMarket]] = {
|
@@ -4,7 +4,6 @@ from datetime import timedelta
|
|
4
4
|
|
5
5
|
import tenacity
|
6
6
|
from web3 import Web3
|
7
|
-
from web3.constants import HASH_ZERO
|
8
7
|
|
9
8
|
from prediction_market_agent_tooling.config import APIKeys
|
10
9
|
from prediction_market_agent_tooling.gtypes import (
|
@@ -28,6 +27,10 @@ from prediction_market_agent_tooling.markets.agent_market import (
|
|
28
27
|
ProcessedTradedMarket,
|
29
28
|
SortBy,
|
30
29
|
)
|
30
|
+
from prediction_market_agent_tooling.markets.blockchain_utils import (
|
31
|
+
get_total_balance,
|
32
|
+
store_trades,
|
33
|
+
)
|
31
34
|
from prediction_market_agent_tooling.markets.data_models import (
|
32
35
|
Bet,
|
33
36
|
BetAmount,
|
@@ -42,9 +45,7 @@ from prediction_market_agent_tooling.markets.omen.data_models import (
|
|
42
45
|
PRESAGIO_BASE_URL,
|
43
46
|
Condition,
|
44
47
|
ConditionPreparationEvent,
|
45
|
-
ContractPrediction,
|
46
48
|
CreatedMarket,
|
47
|
-
IPFSAgentResult,
|
48
49
|
OmenBet,
|
49
50
|
OmenMarket,
|
50
51
|
OmenUserPosition,
|
@@ -55,7 +56,6 @@ from prediction_market_agent_tooling.markets.omen.omen_contracts import (
|
|
55
56
|
OMEN_DEFAULT_MARKET_FEE_PERC,
|
56
57
|
REALITY_DEFAULT_FINALIZATION_TIMEOUT,
|
57
58
|
Arbitrator,
|
58
|
-
OmenAgentResultMappingContract,
|
59
59
|
OmenConditionalTokenContract,
|
60
60
|
OmenFixedProductMarketMakerContract,
|
61
61
|
OmenFixedProductMarketMakerFactoryContract,
|
@@ -74,7 +74,6 @@ from prediction_market_agent_tooling.tools.contract import (
|
|
74
74
|
)
|
75
75
|
from prediction_market_agent_tooling.tools.custom_exceptions import OutOfFundsError
|
76
76
|
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
|
77
|
-
from prediction_market_agent_tooling.tools.ipfs.ipfs_handler import IPFSHandler
|
78
77
|
from prediction_market_agent_tooling.tools.tokens.auto_deposit import (
|
79
78
|
auto_deposit_collateral_token,
|
80
79
|
)
|
@@ -82,7 +81,6 @@ from prediction_market_agent_tooling.tools.tokens.auto_withdraw import (
|
|
82
81
|
auto_withdraw_collateral_token,
|
83
82
|
)
|
84
83
|
from prediction_market_agent_tooling.tools.utils import (
|
85
|
-
BPS_CONSTANT,
|
86
84
|
DatetimeUTC,
|
87
85
|
calculate_sell_amount_in_collateral,
|
88
86
|
check_not_none,
|
@@ -90,7 +88,6 @@ from prediction_market_agent_tooling.tools.utils import (
|
|
90
88
|
from prediction_market_agent_tooling.tools.web3_utils import (
|
91
89
|
add_fraction,
|
92
90
|
get_receipt_block_timestamp,
|
93
|
-
ipfscidv0_to_byte32,
|
94
91
|
remove_fraction,
|
95
92
|
wei_to_xdai,
|
96
93
|
xdai_to_wei,
|
@@ -206,7 +203,7 @@ class OmenAgentMarket(AgentMarket):
|
|
206
203
|
self,
|
207
204
|
outcome: bool,
|
208
205
|
amount: BetAmount,
|
209
|
-
|
206
|
+
auto_deposit: bool = True,
|
210
207
|
web3: Web3 | None = None,
|
211
208
|
api_keys: APIKeys | None = None,
|
212
209
|
) -> str:
|
@@ -222,7 +219,7 @@ class OmenAgentMarket(AgentMarket):
|
|
222
219
|
amount=amount_xdai,
|
223
220
|
market=self,
|
224
221
|
binary_outcome=outcome,
|
225
|
-
auto_deposit=
|
222
|
+
auto_deposit=auto_deposit,
|
226
223
|
web3=web3,
|
227
224
|
)
|
228
225
|
|
@@ -434,38 +431,11 @@ class OmenAgentMarket(AgentMarket):
|
|
434
431
|
keys: APIKeys,
|
435
432
|
agent_name: str,
|
436
433
|
) -> None:
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
traded_market.answer.reasoning if traded_market.answer.reasoning else ""
|
443
|
-
)
|
444
|
-
|
445
|
-
ipfs_hash_decoded = HexBytes(HASH_ZERO)
|
446
|
-
if keys.enable_ipfs_upload:
|
447
|
-
logger.info("Storing prediction on IPFS.")
|
448
|
-
ipfs_hash = IPFSHandler(keys).store_agent_result(
|
449
|
-
IPFSAgentResult(reasoning=reasoning, agent_name=agent_name)
|
450
|
-
)
|
451
|
-
ipfs_hash_decoded = ipfscidv0_to_byte32(ipfs_hash)
|
452
|
-
|
453
|
-
tx_hashes = [
|
454
|
-
HexBytes(HexStr(i.id)) for i in traded_market.trades if i.id is not None
|
455
|
-
]
|
456
|
-
prediction = ContractPrediction(
|
457
|
-
publisher=keys.bet_from_address,
|
458
|
-
ipfs_hash=ipfs_hash_decoded,
|
459
|
-
tx_hashes=tx_hashes,
|
460
|
-
estimated_probability_bps=int(traded_market.answer.p_yes * BPS_CONSTANT),
|
461
|
-
)
|
462
|
-
tx_receipt = OmenAgentResultMappingContract().add_prediction(
|
463
|
-
api_keys=keys,
|
464
|
-
market_address=Web3.to_checksum_address(self.id),
|
465
|
-
prediction=prediction,
|
466
|
-
)
|
467
|
-
logger.info(
|
468
|
-
f"Added prediction to market {self.id}. - receipt {tx_receipt['transactionHash'].hex()}."
|
434
|
+
return store_trades(
|
435
|
+
market_id=self.id,
|
436
|
+
traded_market=traded_market,
|
437
|
+
keys=keys,
|
438
|
+
agent_name=agent_name,
|
469
439
|
)
|
470
440
|
|
471
441
|
@staticmethod
|
@@ -516,8 +486,7 @@ class OmenAgentMarket(AgentMarket):
|
|
516
486
|
cls.get_outcome_str(cls.index_set_to_outcome_index(index_set))
|
517
487
|
)
|
518
488
|
|
519
|
-
|
520
|
-
def get_outcome_str_from_bool(outcome: bool) -> OutcomeStr:
|
489
|
+
def get_outcome_str_from_bool(self, outcome: bool) -> OutcomeStr:
|
521
490
|
return (
|
522
491
|
OutcomeStr(OMEN_TRUE_OUTCOME) if outcome else OutcomeStr(OMEN_FALSE_OUTCOME)
|
523
492
|
)
|
@@ -1302,25 +1271,6 @@ def get_binary_market_p_yes_history(market: OmenAgentMarket) -> list[Probability
|
|
1302
1271
|
return history
|
1303
1272
|
|
1304
1273
|
|
1305
|
-
def get_total_balance(
|
1306
|
-
address: ChecksumAddress,
|
1307
|
-
web3: Web3 | None = None,
|
1308
|
-
sum_xdai: bool = True,
|
1309
|
-
sum_wxdai: bool = True,
|
1310
|
-
) -> xDai:
|
1311
|
-
"""
|
1312
|
-
Checks if the total balance of xDai and wxDai in the wallet is above the minimum required balance.
|
1313
|
-
"""
|
1314
|
-
current_balances = get_balances(address, web3)
|
1315
|
-
# xDai and wxDai have equal value and can be exchanged for almost no cost, so we can sum them up.
|
1316
|
-
total_balance = 0.0
|
1317
|
-
if sum_xdai:
|
1318
|
-
total_balance += current_balances.xdai
|
1319
|
-
if sum_wxdai:
|
1320
|
-
total_balance += current_balances.wxdai
|
1321
|
-
return xdai_type(total_balance)
|
1322
|
-
|
1323
|
-
|
1324
1274
|
def withdraw_wxdai_to_xdai_to_keep_balance(
|
1325
1275
|
api_keys: APIKeys,
|
1326
1276
|
min_required_balance: xDai,
|
prediction_market_agent_tooling-0.58.4/prediction_market_agent_tooling/markets/seer/data_models.py
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
import re
|
2
|
+
import typing as t
|
3
|
+
from enum import Enum
|
4
|
+
from urllib.parse import urljoin
|
5
|
+
|
6
|
+
from pydantic import BaseModel, ConfigDict, Field
|
7
|
+
from web3 import Web3
|
8
|
+
from web3.constants import ADDRESS_ZERO
|
9
|
+
|
10
|
+
from prediction_market_agent_tooling.config import RPCConfig
|
11
|
+
from prediction_market_agent_tooling.gtypes import (
|
12
|
+
ChecksumAddress,
|
13
|
+
HexAddress,
|
14
|
+
HexBytes,
|
15
|
+
Probability,
|
16
|
+
Wei,
|
17
|
+
xdai_type,
|
18
|
+
)
|
19
|
+
from prediction_market_agent_tooling.loggers import logger
|
20
|
+
from prediction_market_agent_tooling.markets.data_models import Resolution
|
21
|
+
from prediction_market_agent_tooling.tools.cow.cow_manager import CowManager
|
22
|
+
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
23
|
+
from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
|
24
|
+
|
25
|
+
|
26
|
+
class CreateCategoricalMarketsParams(BaseModel):
|
27
|
+
model_config = ConfigDict(populate_by_name=True)
|
28
|
+
|
29
|
+
market_name: str = Field(..., alias="marketName")
|
30
|
+
outcomes: list[str]
|
31
|
+
# Only relevant for scalar markets
|
32
|
+
question_start: str = Field(alias="questionStart", default="")
|
33
|
+
question_end: str = Field(alias="questionEnd", default="")
|
34
|
+
outcome_type: str = Field(alias="outcomeType", default="")
|
35
|
+
|
36
|
+
# Not needed for non-conditional markets.
|
37
|
+
parent_outcome: int = Field(alias="parentOutcome", default=0)
|
38
|
+
parent_market: HexAddress = Field(alias="parentMarket", default=ADDRESS_ZERO)
|
39
|
+
|
40
|
+
category: str
|
41
|
+
lang: str
|
42
|
+
lower_bound: int = Field(alias="lowerBound", default=0)
|
43
|
+
upper_bound: int = Field(alias="upperBound", default=0)
|
44
|
+
min_bond: Wei = Field(..., alias="minBond")
|
45
|
+
opening_time: int = Field(..., alias="openingTime")
|
46
|
+
token_names: list[str] = Field(..., alias="tokenNames")
|
47
|
+
|
48
|
+
|
49
|
+
class SeerOutcomeEnum(str, Enum):
|
50
|
+
YES = "yes"
|
51
|
+
NO = "no"
|
52
|
+
INVALID = "invalid"
|
53
|
+
|
54
|
+
@classmethod
|
55
|
+
def from_bool(cls, value: bool) -> "SeerOutcomeEnum":
|
56
|
+
return cls.YES if value else cls.NO
|
57
|
+
|
58
|
+
@classmethod
|
59
|
+
def from_string(cls, value: str) -> "SeerOutcomeEnum":
|
60
|
+
"""Convert a string (case-insensitive) to an Outcome enum."""
|
61
|
+
normalized = value.strip().lower()
|
62
|
+
patterns = {
|
63
|
+
r"^yes$": cls.YES,
|
64
|
+
r"^no$": cls.NO,
|
65
|
+
r"^(invalid|invalid result)$": cls.INVALID,
|
66
|
+
}
|
67
|
+
|
68
|
+
# Search through patterns and return the first match
|
69
|
+
for pattern, outcome in patterns.items():
|
70
|
+
if re.search(pattern, normalized):
|
71
|
+
return outcome
|
72
|
+
|
73
|
+
raise ValueError(f"Could not map {value=} to an outcome.")
|
74
|
+
|
75
|
+
def to_bool(self) -> bool:
|
76
|
+
"""Convert a SeerOutcomeEnum to a boolean value."""
|
77
|
+
if self == self.YES:
|
78
|
+
return True
|
79
|
+
elif self == self.NO:
|
80
|
+
return False
|
81
|
+
elif self == self.INVALID:
|
82
|
+
raise ValueError("Cannot convert INVALID outcome to boolean.")
|
83
|
+
else:
|
84
|
+
raise ValueError(f"Unknown outcome: {self}")
|
85
|
+
|
86
|
+
|
87
|
+
class SeerParentMarket(BaseModel):
|
88
|
+
id: HexBytes
|
89
|
+
|
90
|
+
|
91
|
+
SEER_BASE_URL = "https://app.seer.pm"
|
92
|
+
|
93
|
+
|
94
|
+
class SeerMarket(BaseModel):
|
95
|
+
model_config = ConfigDict(populate_by_name=True)
|
96
|
+
|
97
|
+
id: HexBytes
|
98
|
+
creator: HexAddress
|
99
|
+
title: str = Field(alias="marketName")
|
100
|
+
outcomes: list[str]
|
101
|
+
wrapped_tokens: list[HexAddress] = Field(alias="wrappedTokens")
|
102
|
+
parent_outcome: int = Field(alias="parentOutcome")
|
103
|
+
parent_market: t.Optional[SeerParentMarket] = Field(
|
104
|
+
alias="parentMarket", default=None
|
105
|
+
)
|
106
|
+
collateral_token: HexAddress = Field(alias="collateralToken")
|
107
|
+
condition_id: HexBytes = Field(alias="conditionId")
|
108
|
+
opening_ts: int = Field(alias="openingTs")
|
109
|
+
block_timestamp: int = Field(alias="blockTimestamp")
|
110
|
+
has_answers: bool | None = Field(alias="hasAnswers")
|
111
|
+
payout_reported: bool = Field(alias="payoutReported")
|
112
|
+
payout_numerators: list[int] = Field(alias="payoutNumerators")
|
113
|
+
|
114
|
+
@property
|
115
|
+
def has_valid_answer(self) -> bool:
|
116
|
+
# We assume that, for the market to be resolved as invalid, it must have both:
|
117
|
+
# 1. An invalid outcome AND
|
118
|
+
# 2. Invalid payoutNumerator is 1.
|
119
|
+
|
120
|
+
try:
|
121
|
+
self.outcome_as_enums[SeerOutcomeEnum.INVALID]
|
122
|
+
except KeyError:
|
123
|
+
raise ValueError(
|
124
|
+
f"Market {self.id.hex()} has no invalid outcome. {self.outcomes}"
|
125
|
+
)
|
126
|
+
|
127
|
+
return self.payout_reported and self.payout_numerators[-1] != 1
|
128
|
+
|
129
|
+
@property
|
130
|
+
def outcome_as_enums(self) -> dict[SeerOutcomeEnum, int]:
|
131
|
+
return {
|
132
|
+
SeerOutcomeEnum.from_string(outcome): idx
|
133
|
+
for idx, outcome in enumerate(self.outcomes)
|
134
|
+
}
|
135
|
+
|
136
|
+
@property
|
137
|
+
def is_resolved(self) -> bool:
|
138
|
+
return self.payout_reported
|
139
|
+
|
140
|
+
@property
|
141
|
+
def is_resolved_with_valid_answer(self) -> bool:
|
142
|
+
return self.is_resolved and self.has_valid_answer
|
143
|
+
|
144
|
+
def get_resolution_enum(self) -> t.Optional[Resolution]:
|
145
|
+
if not self.is_resolved_with_valid_answer:
|
146
|
+
return None
|
147
|
+
|
148
|
+
max_idx = self.payout_numerators.index(1)
|
149
|
+
|
150
|
+
outcome: str = self.outcomes[max_idx]
|
151
|
+
outcome_enum = SeerOutcomeEnum.from_string(outcome)
|
152
|
+
if outcome_enum.to_bool():
|
153
|
+
return Resolution.YES
|
154
|
+
return Resolution.NO
|
155
|
+
|
156
|
+
@property
|
157
|
+
def is_binary(self) -> bool:
|
158
|
+
# 3 because Seer has also third, `Invalid` outcome.
|
159
|
+
return len(self.outcomes) == 3
|
160
|
+
|
161
|
+
def boolean_outcome_from_answer(self, answer: HexBytes) -> bool:
|
162
|
+
if not self.is_binary:
|
163
|
+
raise ValueError(
|
164
|
+
f"Market with title {self.title} is not binary, it has {len(self.outcomes)} outcomes."
|
165
|
+
)
|
166
|
+
|
167
|
+
outcome: str = self.outcomes[answer.as_int()]
|
168
|
+
outcome_enum = SeerOutcomeEnum.from_string(outcome)
|
169
|
+
return outcome_enum.to_bool()
|
170
|
+
|
171
|
+
def get_resolution_enum_from_answer(self, answer: HexBytes) -> Resolution:
|
172
|
+
if self.boolean_outcome_from_answer(answer):
|
173
|
+
return Resolution.YES
|
174
|
+
else:
|
175
|
+
return Resolution.NO
|
176
|
+
|
177
|
+
@property
|
178
|
+
def collateral_token_contract_address_checksummed(self) -> ChecksumAddress:
|
179
|
+
return Web3.to_checksum_address(self.collateral_token)
|
180
|
+
|
181
|
+
@property
|
182
|
+
def close_time(self) -> DatetimeUTC:
|
183
|
+
return DatetimeUTC.to_datetime_utc(self.opening_ts)
|
184
|
+
|
185
|
+
@property
|
186
|
+
def created_time(self) -> DatetimeUTC:
|
187
|
+
return DatetimeUTC.to_datetime_utc(self.block_timestamp)
|
188
|
+
|
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 = xdai_to_wei(xdai_type(1))
|
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 / float(quote.quote.buyAmount.root)
|
222
|
+
|
223
|
+
@property
|
224
|
+
def url(self) -> str:
|
225
|
+
chain_id = RPCConfig().chain_id
|
226
|
+
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]
|