Skip to content

Commit

Permalink
Raise OutOfFunds in withdraw_wxdai_to_xdai_to_keep_balance (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Nov 12, 2024
1 parent 3c7e09a commit f30807a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
12 changes: 4 additions & 8 deletions prediction_market_agent_tooling/deploy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
from prediction_market_agent_tooling.monitor.monitor_app import (
MARKET_TYPE_TO_DEPLOYED_AGENT,
)
from prediction_market_agent_tooling.tools.custom_exceptions import (
CantPayForGasError,
OutOfFundsError,
)
from prediction_market_agent_tooling.tools.is_invalid import is_invalid
from prediction_market_agent_tooling.tools.is_predictable import is_predictable_binary
from prediction_market_agent_tooling.tools.langfuse_ import langfuse_context, observe
Expand Down Expand Up @@ -106,14 +110,6 @@ def initialize_langfuse(enable_langfuse: bool) -> None:
Decision = Annotated[bool, BeforeValidator(to_boolean_outcome)]


class CantPayForGasError(ValueError):
pass


class OutOfFundsError(ValueError):
pass


class AnsweredEnum(str, Enum):
ANSWERED = "answered"
NOT_ANSWERED = "not_answered"
Expand Down
3 changes: 2 additions & 1 deletion prediction_market_agent_tooling/markets/omen/omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
init_collateral_token_contract,
to_gnosis_chain_contract,
)
from prediction_market_agent_tooling.tools.custom_exceptions import OutOfFundsError
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
from prediction_market_agent_tooling.tools.ipfs.ipfs_handler import IPFSHandler
from prediction_market_agent_tooling.tools.utils import (
Expand Down Expand Up @@ -1339,7 +1340,7 @@ def withdraw_wxdai_to_xdai_to_keep_balance(
)

if current_balances.wxdai < need_to_withdraw:
raise ValueError(
raise OutOfFundsError(
f"Current wxDai balance {current_balances.wxdai} is less than the required minimum wxDai to withdraw {need_to_withdraw}."
)

Expand Down
6 changes: 6 additions & 0 deletions prediction_market_agent_tooling/tools/custom_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CantPayForGasError(ValueError):
pass


class OutOfFundsError(ValueError):
pass
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prediction-market-agent-tooling"
version = "0.56.2"
version = "0.56.3"
description = "Tools to benchmark, deploy and monitor prediction market agents."
authors = ["Gnosis"]
readme = "README.md"
Expand Down

0 comments on commit f30807a

Please sign in to comment.