prediction-market-agent-tooling 0.58.1__py3-none-any.whl → 0.58.3.dev385__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prediction_market_agent_tooling/tools/omen/sell_positions.py +59 -0
- prediction_market_agent_tooling/tools/web3_utils.py +7 -0
- {prediction_market_agent_tooling-0.58.1.dist-info → prediction_market_agent_tooling-0.58.3.dev385.dist-info}/METADATA +2 -2
- {prediction_market_agent_tooling-0.58.1.dist-info → prediction_market_agent_tooling-0.58.3.dev385.dist-info}/RECORD +7 -6
- {prediction_market_agent_tooling-0.58.1.dist-info → prediction_market_agent_tooling-0.58.3.dev385.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.58.1.dist-info → prediction_market_agent_tooling-0.58.3.dev385.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.58.1.dist-info → prediction_market_agent_tooling-0.58.3.dev385.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
from datetime import timedelta
|
2
|
+
|
3
|
+
from prediction_market_agent_tooling.config import APIKeys
|
4
|
+
from prediction_market_agent_tooling.loggers import logger
|
5
|
+
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
|
6
|
+
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
7
|
+
OmenSubgraphHandler,
|
8
|
+
)
|
9
|
+
from prediction_market_agent_tooling.tools.balances import get_balances
|
10
|
+
from prediction_market_agent_tooling.tools.utils import utcnow
|
11
|
+
|
12
|
+
|
13
|
+
def sell_all(
|
14
|
+
api_keys: APIKeys,
|
15
|
+
closing_later_than_days: int,
|
16
|
+
auto_withdraw: bool = False,
|
17
|
+
) -> None:
|
18
|
+
"""
|
19
|
+
Helper function to sell all existing outcomes on Omen that would resolve later than in X days.
|
20
|
+
"""
|
21
|
+
better_address = api_keys.bet_from_address
|
22
|
+
bets = OmenSubgraphHandler().get_bets(
|
23
|
+
better_address=better_address,
|
24
|
+
market_opening_after=utcnow() + timedelta(days=closing_later_than_days),
|
25
|
+
)
|
26
|
+
bets_total_usd = sum(b.collateral_amount_usd for b in bets)
|
27
|
+
unique_market_urls = set(b.fpmm.url for b in bets)
|
28
|
+
starting_balance = get_balances(better_address)
|
29
|
+
new_balance = starting_balance
|
30
|
+
|
31
|
+
logger.info(
|
32
|
+
f"For {better_address}, found the following {len(bets)} bets on {len(unique_market_urls)} unique markets worth of {bets_total_usd} USD: {unique_market_urls}"
|
33
|
+
)
|
34
|
+
|
35
|
+
for bet in bets:
|
36
|
+
agent_market = OmenAgentMarket.from_data_model(bet.fpmm)
|
37
|
+
outcome = agent_market.outcomes[bet.outcomeIndex]
|
38
|
+
current_token_balance = agent_market.get_token_balance(better_address, outcome)
|
39
|
+
|
40
|
+
if current_token_balance.amount <= OmenAgentMarket.get_tiny_bet_amount().amount:
|
41
|
+
logger.info(
|
42
|
+
f"Skipping bet on {bet.fpmm.url} because the actual balance is unreasonably low {current_token_balance.amount}."
|
43
|
+
)
|
44
|
+
continue
|
45
|
+
|
46
|
+
old_balance = new_balance
|
47
|
+
agent_market.sell_tokens(
|
48
|
+
bet.boolean_outcome,
|
49
|
+
current_token_balance,
|
50
|
+
auto_withdraw=auto_withdraw,
|
51
|
+
api_keys=api_keys,
|
52
|
+
)
|
53
|
+
new_balance = get_balances(better_address)
|
54
|
+
|
55
|
+
logger.info(
|
56
|
+
f"Sold bet on {bet.fpmm.url} for {new_balance.wxdai - old_balance.wxdai} xDai."
|
57
|
+
)
|
58
|
+
|
59
|
+
logger.info(f"Obtained back {new_balance.wxdai - starting_balance.wxdai} wxDai.")
|
@@ -351,6 +351,13 @@ def byte32_to_ipfscidv0(hex: HexBytes) -> IPFSCIDVersion0:
|
|
351
351
|
return IPFSCIDVersion0(base58.b58encode(completed_binary_str).decode("utf-8"))
|
352
352
|
|
353
353
|
|
354
|
+
@tenacity.retry(
|
355
|
+
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1, 10)]),
|
356
|
+
stop=tenacity.stop_after_attempt(5),
|
357
|
+
after=lambda x: logger.debug(
|
358
|
+
f"get_receipt_block_timestamp failed, {x.attempt_number=}."
|
359
|
+
),
|
360
|
+
)
|
354
361
|
def get_receipt_block_timestamp(receipt_tx: TxReceipt, web3: Web3) -> int:
|
355
362
|
block_number = receipt_tx["blockNumber"]
|
356
363
|
block = web3.eth.get_block(block_number)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.58.
|
3
|
+
Version: 0.58.3.dev385
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.13
|
@@ -39,7 +39,7 @@ Requires-Dist: optuna (>=4.1.0,<5.0.0) ; extra == "optuna"
|
|
39
39
|
Requires-Dist: pinatapy-vourhey (>=0.2.0,<0.3.0)
|
40
40
|
Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
|
41
41
|
Requires-Dist: proto-plus (>=1.0.0,<2.0.0)
|
42
|
-
Requires-Dist: protobuf (>=
|
42
|
+
Requires-Dist: protobuf (>=5.0.0,<6.0.0)
|
43
43
|
Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
|
44
44
|
Requires-Dist: pydantic (>=2.6.1,<3.0.0)
|
45
45
|
Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
|
@@ -102,6 +102,7 @@ prediction_market_agent_tooling/tools/is_predictable.py,sha256=qVd6zqay2Dg2fyeAu
|
|
102
102
|
prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
|
103
103
|
prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=83T31s-YbsnNBLyYCjmBI2BBKUEqJUuYFa0uCdkoqy8,5901
|
104
104
|
prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1gVlQSTskdVFTn09uPLST23YeipVIWj54io,2236
|
105
|
+
prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=JIfTMKF0bHyQ9qXNfyr5ul_eu4hBuydlRVGJET8Uw90,2308
|
105
106
|
prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
|
106
107
|
prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py,sha256=95l84aztFaxcRLLcRQ46yKJbIlOEuDAbIGLouyliDzA,1316
|
107
108
|
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=CddJem7tk15NAudJDwmuL8znTycbR-YI8kTNtd3LzG8,5474
|
@@ -116,9 +117,9 @@ prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=B02maQkl3wN
|
|
116
117
|
prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=5iHO7-iehSlXuue6ocVrr4IsklVjm7QHIwln4BsebJA,573
|
117
118
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
118
119
|
prediction_market_agent_tooling/tools/utils.py,sha256=jLG4nbEoIzzJiZ4RgMx4Q969Zdl0p0s63p8uET_0Fuw,6440
|
119
|
-
prediction_market_agent_tooling/tools/web3_utils.py,sha256=
|
120
|
-
prediction_market_agent_tooling-0.58.
|
121
|
-
prediction_market_agent_tooling-0.58.
|
122
|
-
prediction_market_agent_tooling-0.58.
|
123
|
-
prediction_market_agent_tooling-0.58.
|
124
|
-
prediction_market_agent_tooling-0.58.
|
120
|
+
prediction_market_agent_tooling/tools/web3_utils.py,sha256=e7lqqQddVZaa905rhBb6L1fC3o39Yr-PDJsJjHFBeRE,12523
|
121
|
+
prediction_market_agent_tooling-0.58.3.dev385.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
122
|
+
prediction_market_agent_tooling-0.58.3.dev385.dist-info/METADATA,sha256=BUNlEFZXKyo10bb9d49r_eyTZgC8tRHExC6OukNMZFU,8636
|
123
|
+
prediction_market_agent_tooling-0.58.3.dev385.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
124
|
+
prediction_market_agent_tooling-0.58.3.dev385.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
125
|
+
prediction_market_agent_tooling-0.58.3.dev385.dist-info/RECORD,,
|
File without changes
|
File without changes
|