prediction-market-agent-tooling 0.39.5__tar.gz → 0.40.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.39.5 → prediction_market_agent_tooling-0.40.0}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/config.py +5 -5
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/agent.py +8 -2
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen.py +37 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/pyproject.toml +1 -1
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/README.md +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/wxdai.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/cache.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/google.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.5 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -58,14 +58,14 @@ class APIKeys(BaseSettings):
|
|
58
58
|
"BET_FROM_PRIVATE_KEY missing in the environment.",
|
59
59
|
)
|
60
60
|
|
61
|
+
@property
|
62
|
+
def public_key(self) -> ChecksumAddress:
|
63
|
+
return private_key_to_public_key(self.bet_from_private_key)
|
64
|
+
|
61
65
|
@property
|
62
66
|
def bet_from_address(self) -> ChecksumAddress:
|
63
67
|
"""If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
|
64
|
-
return
|
65
|
-
self.SAFE_ADDRESS
|
66
|
-
if self.SAFE_ADDRESS
|
67
|
-
else private_key_to_public_key(self.bet_from_private_key)
|
68
|
-
)
|
68
|
+
return self.SAFE_ADDRESS if self.SAFE_ADDRESS else self.public_key
|
69
69
|
|
70
70
|
@property
|
71
71
|
def openai_api_key(self) -> SecretStr:
|
@@ -22,7 +22,7 @@ from prediction_market_agent_tooling.deploy.gcp.utils import (
|
|
22
22
|
gcp_function_is_active,
|
23
23
|
gcp_resolve_api_keys_secrets,
|
24
24
|
)
|
25
|
-
from prediction_market_agent_tooling.gtypes import Probability
|
25
|
+
from prediction_market_agent_tooling.gtypes import Probability, xdai_type
|
26
26
|
from prediction_market_agent_tooling.loggers import logger
|
27
27
|
from prediction_market_agent_tooling.markets.agent_market import (
|
28
28
|
AgentMarket,
|
@@ -36,6 +36,7 @@ from prediction_market_agent_tooling.markets.markets import (
|
|
36
36
|
)
|
37
37
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
38
38
|
redeem_from_all_user_positions,
|
39
|
+
withdraw_wxdai_to_xdai_to_keep_balance,
|
39
40
|
)
|
40
41
|
from prediction_market_agent_tooling.monitor.langfuse.langfuse_wrapper import (
|
41
42
|
LangfuseWrapper,
|
@@ -260,9 +261,14 @@ class DeployableTraderAgent(DeployableAgent):
|
|
260
261
|
"""
|
261
262
|
Executes actions that occur before bets are placed.
|
262
263
|
"""
|
264
|
+
api_keys = APIKeys()
|
263
265
|
if market_type == MarketType.OMEN:
|
264
266
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
265
|
-
redeem_from_all_user_positions(
|
267
|
+
redeem_from_all_user_positions(api_keys)
|
268
|
+
# Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
|
269
|
+
withdraw_wxdai_to_xdai_to_keep_balance(
|
270
|
+
api_keys, min_required_balance=xdai_type(1), withdraw_multiplier=2
|
271
|
+
)
|
266
272
|
|
267
273
|
def process_bets(self, market_type: MarketType) -> None:
|
268
274
|
"""
|
@@ -1000,3 +1000,40 @@ def get_binary_market_p_yes_history(market: OmenAgentMarket) -> list[Probability
|
|
1000
1000
|
)
|
1001
1001
|
|
1002
1002
|
return history
|
1003
|
+
|
1004
|
+
|
1005
|
+
def withdraw_wxdai_to_xdai_to_keep_balance(
|
1006
|
+
api_keys: APIKeys,
|
1007
|
+
min_required_balance: xDai,
|
1008
|
+
withdraw_multiplier: float = 1.0,
|
1009
|
+
web3: Web3 | None = None,
|
1010
|
+
) -> None:
|
1011
|
+
"""
|
1012
|
+
Keeps xDai balance above the minimum required balance by withdrawing wxDai to xDai.
|
1013
|
+
Optionally, the amount to withdraw can be multiplied by the `withdraw_multiplier`, which can be useful to keep a buffer.
|
1014
|
+
"""
|
1015
|
+
# xDai needs to be in our wallet where we pay transaction fees, so do not check for Safe's balance.
|
1016
|
+
current_balances = get_balances(api_keys.public_key, web3)
|
1017
|
+
|
1018
|
+
if current_balances.xdai >= min_required_balance:
|
1019
|
+
logger.info(
|
1020
|
+
f"Current xDai balance {current_balances.xdai} is more or equal than the required minimum balance {min_required_balance}."
|
1021
|
+
)
|
1022
|
+
return
|
1023
|
+
|
1024
|
+
need_to_withdraw = xDai(
|
1025
|
+
(min_required_balance - current_balances.xdai) * withdraw_multiplier
|
1026
|
+
)
|
1027
|
+
|
1028
|
+
if current_balances.wxdai < need_to_withdraw:
|
1029
|
+
raise ValueError(
|
1030
|
+
f"Current wxDai balance {current_balances.wxdai} is less than the required minimum wxDai to withdraw {need_to_withdraw}."
|
1031
|
+
)
|
1032
|
+
|
1033
|
+
collateral_token_contract = OmenCollateralTokenContract()
|
1034
|
+
collateral_token_contract.withdraw(
|
1035
|
+
api_keys=api_keys, amount_wei=xdai_to_wei(need_to_withdraw), web3=web3
|
1036
|
+
)
|
1037
|
+
logger.info(
|
1038
|
+
f"Withdrew {need_to_withdraw} wxDai to keep the balance above the minimum required balance {min_required_balance}."
|
1039
|
+
)
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|