prediction-market-agent-tooling 0.15.0__tar.gz → 0.16.0__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.15.0 → prediction_market_agent_tooling-0.16.0}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/benchmark/utils.py +4 -0
- prediction_market_agent_tooling-0.15.0/prediction_market_agent_tooling/markets/omen/omen_resolve_replicated.py → prediction_market_agent_tooling-0.16.0/prediction_market_agent_tooling/markets/omen/omen_resolving.py +5 -80
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/pyproject.toml +1 -1
- prediction_market_agent_tooling-0.15.0/prediction_market_agent_tooling/markets/omen/omen_replicate.py +0 -184
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/README.md +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/abis/wxdai.abi.json +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/agent.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/omen/omen.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/cache.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/google.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.15.0 → prediction_market_agent_tooling-0.16.0}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -80,6 +80,10 @@ def get_llm_api_call_cost(
|
|
80
80
|
"prompt_tokens": 0.01,
|
81
81
|
"completion_tokens": 0.03,
|
82
82
|
},
|
83
|
+
"gpt-4-turbo-2024-04-09": {
|
84
|
+
"prompt_tokens": 0.01,
|
85
|
+
"completion_tokens": 0.03,
|
86
|
+
},
|
83
87
|
"gpt-3.5-turbo-0125": {
|
84
88
|
"prompt_tokens": 0.0005,
|
85
89
|
"completion_tokens": 0.0015,
|
@@ -1,7 +1,4 @@
|
|
1
|
-
from datetime import timedelta
|
2
|
-
|
3
1
|
from loguru import logger
|
4
|
-
from pydantic import BaseModel
|
5
2
|
from web3 import Web3
|
6
3
|
|
7
4
|
from prediction_market_agent_tooling.config import PrivateCredentials
|
@@ -34,81 +31,10 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
|
34
31
|
from prediction_market_agent_tooling.markets.polymarket.utils import (
|
35
32
|
find_resolution_on_polymarket,
|
36
33
|
)
|
37
|
-
from prediction_market_agent_tooling.tools.balances import get_balances
|
38
|
-
from prediction_market_agent_tooling.tools.utils import utcnow
|
39
34
|
from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES, xdai_to_wei
|
40
35
|
|
41
36
|
|
42
|
-
|
43
|
-
finalized: list[HexAddress]
|
44
|
-
resolved: list[HexAddress]
|
45
|
-
claimed_question_ids: list[HexBytes]
|
46
|
-
|
47
|
-
|
48
|
-
def omen_finalize_and_resolve_and_claim_back_all_markets_based_on_others_tx(
|
49
|
-
private_credentials: PrivateCredentials,
|
50
|
-
) -> FinalizeAndResolveResult:
|
51
|
-
public_key = private_credentials.public_key
|
52
|
-
balances_start = get_balances(public_key)
|
53
|
-
logger.info(f"{balances_start=}")
|
54
|
-
|
55
|
-
# Just to be friendly with timezones.
|
56
|
-
before = utcnow() - timedelta(hours=8)
|
57
|
-
|
58
|
-
# Fetch markets created by us that are already open, but no answer was submitted yet.
|
59
|
-
created_opened_markets = OmenSubgraphHandler().get_omen_binary_markets(
|
60
|
-
limit=None,
|
61
|
-
creator=public_key,
|
62
|
-
opened_before=before,
|
63
|
-
finalized=False,
|
64
|
-
)
|
65
|
-
# Finalize them (set answer on Realitio).
|
66
|
-
finalized_markets = finalize_markets(
|
67
|
-
private_credentials,
|
68
|
-
created_opened_markets,
|
69
|
-
)
|
70
|
-
balances_after_finalization = get_balances(public_key)
|
71
|
-
logger.info(f"{balances_after_finalization=}")
|
72
|
-
|
73
|
-
# Fetch markets created by us that are already open, and we already submitted an answer more than a day ago, but they aren't resolved yet.
|
74
|
-
created_finalized_markets = OmenSubgraphHandler().get_omen_binary_markets(
|
75
|
-
limit=None,
|
76
|
-
creator=public_key,
|
77
|
-
finalized_before=before - timedelta(hours=24),
|
78
|
-
resolved=False,
|
79
|
-
)
|
80
|
-
# Resolve them (resolve them on Oracle).
|
81
|
-
resolved_markets = resolve_markets(
|
82
|
-
private_credentials,
|
83
|
-
created_finalized_markets,
|
84
|
-
)
|
85
|
-
balances_after_resolution = get_balances(public_key)
|
86
|
-
logger.info(f"{balances_after_resolution=}")
|
87
|
-
|
88
|
-
# Fetch questions that are already finalised (last answer is older than 24 hours), but we didn't claim the bonded xDai yet.
|
89
|
-
created_not_claimed_questions: list[
|
90
|
-
RealityQuestion
|
91
|
-
] = OmenSubgraphHandler().get_questions(
|
92
|
-
user=public_key,
|
93
|
-
claimed=False,
|
94
|
-
current_answer_before=before - timedelta(hours=24),
|
95
|
-
)
|
96
|
-
claimed_question_ids = claim_bonds_on_realitio_quetions(
|
97
|
-
private_credentials,
|
98
|
-
created_not_claimed_questions,
|
99
|
-
auto_withdraw=True,
|
100
|
-
)
|
101
|
-
balances_after_claiming = get_balances(public_key)
|
102
|
-
logger.info(f"{balances_after_claiming=}")
|
103
|
-
|
104
|
-
return FinalizeAndResolveResult(
|
105
|
-
finalized=finalized_markets,
|
106
|
-
resolved=resolved_markets,
|
107
|
-
claimed_question_ids=claimed_question_ids,
|
108
|
-
)
|
109
|
-
|
110
|
-
|
111
|
-
def claim_bonds_on_realitio_quetions(
|
37
|
+
def claim_bonds_on_realitio_questions(
|
112
38
|
private_credentials: PrivateCredentials,
|
113
39
|
questions: list[RealityQuestion],
|
114
40
|
auto_withdraw: bool,
|
@@ -194,18 +120,17 @@ def claim_bonds_on_realitio_question(
|
|
194
120
|
|
195
121
|
def finalize_markets(
|
196
122
|
private_credentials: PrivateCredentials,
|
197
|
-
|
123
|
+
markets_with_resolutions: list[tuple[OmenMarket, Resolution | None]],
|
198
124
|
) -> list[HexAddress]:
|
199
125
|
finalized_markets: list[HexAddress] = []
|
200
126
|
|
201
|
-
for idx, market in enumerate(
|
127
|
+
for idx, (market, resolution) in enumerate(markets_with_resolutions):
|
202
128
|
logger.info(
|
203
|
-
f"[{idx+1} / {len(
|
129
|
+
f"[{idx+1} / {len(markets_with_resolutions)}] Looking into {market.url=} {market.question_title=}"
|
204
130
|
)
|
205
|
-
resolution = find_resolution_on_other_markets(market)
|
206
131
|
|
207
132
|
if resolution is None:
|
208
|
-
logger.error(f"No resolution
|
133
|
+
logger.error(f"No resolution provided for {market.url=}")
|
209
134
|
|
210
135
|
elif resolution in (Resolution.YES, Resolution.NO):
|
211
136
|
logger.info(f"Found resolution {resolution.value=} for {market.url=}")
|
@@ -1,184 +0,0 @@
|
|
1
|
-
from datetime import datetime, timedelta
|
2
|
-
|
3
|
-
from loguru import logger
|
4
|
-
|
5
|
-
from prediction_market_agent_tooling.config import PrivateCredentials
|
6
|
-
from prediction_market_agent_tooling.gtypes import ChecksumAddress, wei_type, xDai
|
7
|
-
from prediction_market_agent_tooling.markets.agent_market import FilterBy, SortBy
|
8
|
-
from prediction_market_agent_tooling.markets.categorize import infer_category
|
9
|
-
from prediction_market_agent_tooling.markets.markets import (
|
10
|
-
MarketType,
|
11
|
-
get_binary_markets,
|
12
|
-
)
|
13
|
-
from prediction_market_agent_tooling.markets.omen.data_models import (
|
14
|
-
OMEN_FALSE_OUTCOME,
|
15
|
-
OMEN_TRUE_OUTCOME,
|
16
|
-
)
|
17
|
-
from prediction_market_agent_tooling.markets.omen.omen import (
|
18
|
-
OMEN_DEFAULT_MARKET_FEE,
|
19
|
-
OmenAgentMarket,
|
20
|
-
omen_create_market_tx,
|
21
|
-
omen_remove_fund_market_tx,
|
22
|
-
)
|
23
|
-
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
24
|
-
OmenSubgraphHandler,
|
25
|
-
)
|
26
|
-
from prediction_market_agent_tooling.tools.is_predictable import is_predictable_binary
|
27
|
-
from prediction_market_agent_tooling.tools.utils import utcnow
|
28
|
-
|
29
|
-
# According to Omen's recommendation, closing time of the market should be at least 6 days after the outcome is known.
|
30
|
-
# That is because at the closing time, the question will open on Realitio, and we don't want it to be resolved as unknown/invalid.
|
31
|
-
# All replicated markets that close at N, needs to have closing time on Realition N + `EXTEND_CLOSING_TIME_DELTA`.
|
32
|
-
EXTEND_CLOSING_TIME_DELTA = timedelta(days=6)
|
33
|
-
|
34
|
-
|
35
|
-
def omen_replicate_from_tx(
|
36
|
-
private_credentials: PrivateCredentials,
|
37
|
-
market_type: MarketType,
|
38
|
-
n_to_replicate: int,
|
39
|
-
initial_funds: xDai,
|
40
|
-
close_time_before: datetime | None = None,
|
41
|
-
auto_deposit: bool = False,
|
42
|
-
) -> list[ChecksumAddress]:
|
43
|
-
from_address = private_credentials.public_key
|
44
|
-
already_created_markets = OmenSubgraphHandler().get_omen_binary_markets(
|
45
|
-
limit=None,
|
46
|
-
creator=from_address,
|
47
|
-
)
|
48
|
-
|
49
|
-
markets = get_binary_markets(
|
50
|
-
# Polymarket is slow to get, so take only 10 candidates for him.
|
51
|
-
10 if market_type == MarketType.POLYMARKET else 100,
|
52
|
-
market_type,
|
53
|
-
filter_by=FilterBy.OPEN,
|
54
|
-
sort_by=SortBy.NONE,
|
55
|
-
excluded_questions=set(m.question_title for m in already_created_markets),
|
56
|
-
)
|
57
|
-
markets_sorted = sorted(
|
58
|
-
markets,
|
59
|
-
key=lambda m: m.volume or 0,
|
60
|
-
reverse=True,
|
61
|
-
)
|
62
|
-
markets_to_replicate = [
|
63
|
-
m
|
64
|
-
for m in markets_sorted
|
65
|
-
if close_time_before is None
|
66
|
-
or (m.close_time is not None and m.close_time <= close_time_before)
|
67
|
-
]
|
68
|
-
if not markets_to_replicate:
|
69
|
-
logger.info(f"No markets found for {market_type}")
|
70
|
-
return []
|
71
|
-
|
72
|
-
logger.info(f"Found {len(markets_to_replicate)} markets to replicate.")
|
73
|
-
|
74
|
-
# Get a set of possible categories from existing markets (but created by anyone, not just your agent)
|
75
|
-
existing_categories = set(
|
76
|
-
m.category
|
77
|
-
for m in OmenSubgraphHandler().get_omen_binary_markets_simple(
|
78
|
-
limit=1000,
|
79
|
-
sort_by=SortBy.NEWEST,
|
80
|
-
filter_by=FilterBy.NONE,
|
81
|
-
)
|
82
|
-
)
|
83
|
-
|
84
|
-
created_addresses: list[ChecksumAddress] = []
|
85
|
-
|
86
|
-
for market in markets_to_replicate:
|
87
|
-
if market.close_time is None:
|
88
|
-
logger.info(
|
89
|
-
f"Skipping `{market.question}` because it's missing the closing time."
|
90
|
-
)
|
91
|
-
continue
|
92
|
-
|
93
|
-
safe_closing_time = market.close_time + EXTEND_CLOSING_TIME_DELTA
|
94
|
-
# Force at least 48 hours of time where the resolution is unknown.
|
95
|
-
soonest_allowed_resolution_known_time = utcnow() + timedelta(hours=48)
|
96
|
-
if market.close_time <= soonest_allowed_resolution_known_time:
|
97
|
-
logger.info(
|
98
|
-
f"Skipping `{market.question}` because it closes sooner than {soonest_allowed_resolution_known_time}."
|
99
|
-
)
|
100
|
-
continue
|
101
|
-
|
102
|
-
# Do as the last step, becuase it calls OpenAI (costly & slow).
|
103
|
-
if not is_predictable_binary(market.question):
|
104
|
-
logger.info(
|
105
|
-
f"Skipping `{market.question}` because it seems to not be predictable."
|
106
|
-
)
|
107
|
-
continue
|
108
|
-
|
109
|
-
category = infer_category(market.question, existing_categories)
|
110
|
-
# Realitio will allow new categories or misformated categories, so double check that the LLM got it right.
|
111
|
-
if category not in existing_categories:
|
112
|
-
logger.info(
|
113
|
-
f"Error: LLM went rouge. Skipping `{market.question}` because the category `{category}` is not in the existing categories {existing_categories}."
|
114
|
-
)
|
115
|
-
continue
|
116
|
-
|
117
|
-
market_address = omen_create_market_tx(
|
118
|
-
private_credentials=private_credentials,
|
119
|
-
initial_funds=initial_funds,
|
120
|
-
fee=OMEN_DEFAULT_MARKET_FEE,
|
121
|
-
question=market.question,
|
122
|
-
closing_time=safe_closing_time,
|
123
|
-
category=category,
|
124
|
-
language="en",
|
125
|
-
outcomes=[OMEN_TRUE_OUTCOME, OMEN_FALSE_OUTCOME],
|
126
|
-
auto_deposit=auto_deposit,
|
127
|
-
)
|
128
|
-
created_addresses.append(market_address)
|
129
|
-
logger.info(
|
130
|
-
f"Created `https://aiomen.eth.limo/#/{market_address}` for `{market.question}` in category {category} out of {market.url}."
|
131
|
-
)
|
132
|
-
|
133
|
-
if len(created_addresses) >= n_to_replicate:
|
134
|
-
logger.info(
|
135
|
-
f"Replicated {len(created_addresses)} from {market_type}, breaking."
|
136
|
-
)
|
137
|
-
break
|
138
|
-
|
139
|
-
return created_addresses
|
140
|
-
|
141
|
-
|
142
|
-
def omen_unfund_replicated_known_markets_tx(
|
143
|
-
private_credentials: PrivateCredentials,
|
144
|
-
saturation_above_threshold: float | None = None,
|
145
|
-
) -> None:
|
146
|
-
from_address = private_credentials.public_key
|
147
|
-
|
148
|
-
now = utcnow()
|
149
|
-
# We want to unfund markets ~1 day before the resolution should be known.
|
150
|
-
# That is, if the original market would be closing now, but we added `EXTEND_CLOSING_TIME_DELTA` to it,
|
151
|
-
# we want to unfund any market that closes sooner than NOW + `EXTEND_CLOSING_TIME_DELTA` - 1 day.
|
152
|
-
opened_before = now + EXTEND_CLOSING_TIME_DELTA - timedelta(days=1)
|
153
|
-
|
154
|
-
# Fetch markets that we created, are soon to be known,
|
155
|
-
# and still have liquidity in them (we didn't withdraw it yet).
|
156
|
-
markets = OmenSubgraphHandler().get_omen_binary_markets(
|
157
|
-
limit=None,
|
158
|
-
creator=from_address,
|
159
|
-
opened_before=opened_before,
|
160
|
-
liquidity_bigger_than=wei_type(0),
|
161
|
-
)
|
162
|
-
|
163
|
-
for idx, market in enumerate(markets):
|
164
|
-
# Optionally, if `saturation_above_threshold` is provided, skip markets that are not saturated to leave some free money motivation for agents.
|
165
|
-
if (
|
166
|
-
saturation_above_threshold is not None
|
167
|
-
and not market.is_resolved
|
168
|
-
and not (
|
169
|
-
market.current_p_yes > saturation_above_threshold
|
170
|
-
or market.current_p_no > saturation_above_threshold
|
171
|
-
)
|
172
|
-
):
|
173
|
-
logger.info(
|
174
|
-
f"[{idx+1}/{len(markets)}] Skipping unfunding of `{market.liquidityParameter=} {market.question=} {market.url=}`, because it's not saturated yet, `{market.current_p_yes=}`."
|
175
|
-
)
|
176
|
-
continue
|
177
|
-
logger.info(
|
178
|
-
f"[{idx+1}/{len(markets)}] Unfunding market `{market.liquidityParameter=} {market.question=} {market.url=}`."
|
179
|
-
)
|
180
|
-
omen_remove_fund_market_tx(
|
181
|
-
private_credentials=private_credentials,
|
182
|
-
market=OmenAgentMarket.from_data_model(market),
|
183
|
-
shares=None,
|
184
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|